BINARY_SCALE = 1024
DECIMAL_SCALE = 10000

FRAME_PER_SECOND = 16

LEVEL = 120
LEVEL_SCALE = 450
LEVEL_CONSTANT = 45750
LEVEL_REDUCTION = 0.05

DOT_DAMAGE_SCALE = 12
PHYSICAL_DAMAGE_SCALE = 10
MAGICAL_DAMAGE_SCALE = 12

CRITICAL_STRIKE_SCALE = 9.530 * (LEVEL_SCALE * LEVEL - LEVEL_CONSTANT)
CRITICAL_POWER_SCALE = 3.335 * (LEVEL_SCALE * LEVEL - LEVEL_CONSTANT)
OVERCOME_SCALE = 9.530 * (LEVEL_SCALE * LEVEL - LEVEL_CONSTANT)
HASTE_SCALE = 11.695 * (LEVEL_SCALE * LEVEL - LEVEL_CONSTANT)
STRAIN_SCALE = 9.189 * (LEVEL_SCALE * LEVEL - LEVEL_CONSTANT)
DEFAULT_SURPLUS_COF = 13.192

SHIELD_SCALE = 5.091

SHIELD_BASE_MAP = {
    124: 27550,
    123: 26317,
    122: 15528,
    121: 11073,
    120: 7414
}
SHIELD_CONSTANT_MAP = {
    level: SHIELD_SCALE * (LEVEL_SCALE * level - LEVEL_CONSTANT) for level in SHIELD_BASE_MAP
}
LEVEL_REDUCTION_MAP = {
    level: LEVEL_REDUCTION * (level - LEVEL) for level in SHIELD_BASE_MAP
}

MAJOR_BASE = 41
BASE_CRITICAL_POWER = 1.75

AGILITY_TO_CRITICAL_STRIKE = 0.64
STRENGTH_TO_ATTACK_POWER = 0.15
STRENGTH_TO_OVERCOME = 0.3
SPIRIT_TO_CRITICAL_STRIKE = 0.64
SPUNK_TO_ATTACK_POWER = 0.18
SPUNK_TO_OVERCOME = 0.3

DELTA_SCALE = 1
MAJOR_DELTA = 218
PHYSICAL_DELTA = 439
MAGICAL_DELTA = 524
MINOR_DELTA = 974
WEAPON_DELTA = 658


def PHYSICAL_ATTACK_POWER_COF(cof):
    return int(cof) / FRAME_PER_SECOND / PHYSICAL_DAMAGE_SCALE


def PHYSICAL_DOT_ATTACK_POWER_COF(cof, interval, tick):
    cof = int(cof) * int(max(FRAME_PER_SECOND, interval * tick / DOT_DAMAGE_SCALE))
    return cof / FRAME_PER_SECOND / tick / FRAME_PER_SECOND / PHYSICAL_DAMAGE_SCALE


def MAGICAL_ATTACK_POWER_COF(cof):
    return int(cof) / FRAME_PER_SECOND / MAGICAL_DAMAGE_SCALE


def MAGICAL_DOT_ATTACK_POWER_COF(cof, interval, tick):
    cof = int(cof) * int(max(FRAME_PER_SECOND, interval * tick / DOT_DAMAGE_SCALE))
    return cof / FRAME_PER_SECOND / tick / FRAME_PER_SECOND / MAGICAL_DAMAGE_SCALE


def SURPLUS_COF(cof):
    return int(cof) / BINARY_SCALE


def WEAPON_DAMAGE_COF(cof):
    return int(cof) / BINARY_SCALE


def GLOBAL_DAMAGE_COF(cof):
    return (int(cof) / BINARY_SCALE + BINARY_SCALE) / BINARY_SCALE
